<?php

namespace mpend\modules\exmall\controllers;

use Yii;
use mpend\components\Controller;
use common\helpers\Url;
use mpend\models\searchs\AssembleProductSearch;

/**
 * 兑换商城首页
 * Default controller for the `exmall` module
 */
class DefaultController extends Controller {

    /**
     * @inheritdoc
     */
    public function actionIndex() {
        /* @var $model \apiend\modules\shop\models\AssembleProductSearch */
        $model = new AssembleProductSearch();
        $model->tag = 'recommend';
        $recommend = $model->limitsSearch(3);
        $model->tag = 'hot';
        $hot = $model->limitsSearch(3);
        $username = $this->token->user ? $this->token->user->username : 'test';
        return [
            'carousels' => [
                Url::attach('discover/01.png'),
                Url::attach('discover/02.png'),
                Url::attach('discover/03.png'),
            ],
            'categories' => [
                [
                    'id' => 1,
                    'title' => '积分',
                    'link' => Url::h5('credit'),
                    'thumb' => Url::attach('discover/navigation/01.png')
                ],
                [
                    'id' => 2,
                    'title' => '活动',
                    'link' => Url::h5('activity/1'),
                    'thumb' => Url::attach('discover/navigation/02.png')
                ],
                [
                    'id' => 4,
                    'title' => '攻略',
                    'link' => Url::h5('strategy'),
                    'thumb' => Url::attach('discover/navigation/03.png')
                ],
                [
                    'id' => 5,
                    'title' => '培训',
                    'link' => Url::h5('train'),
                    'thumb' => Url::attach('discover/navigation/04.png')
                ],
            ],
            'spread' => [
                [
                    'title' => '激活礼包',
                    'description' => '新用户注册即送激活大礼包',
                    'thumb' => Url::attach('discover/spread/01.png')
                ],
                [
                    'title' => '新购奖励',
                    'description' => '新购即送100积分',
                    'thumb' => Url::attach('discover/spread/02.png')
                ],
                [
                    'title' => '推广奖励',
                    'description' => '发送给朋友',
                    'thumb' => Url::attach('discover/spread/03.png')
                ],
            ],
            'actgoods' => $hot,
            'recommends' => $recommend,
        ];
    }

}
